package com.example.demo;

import com.v5ba.api.Animal;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;

@Configurable
public class CustomConfiguration {

    @Bean
    public Api api(){
        Api bean = new Api();
        bean.setUrl("http://v5ba.cn");
        bean.setParam("张三");
        return bean;
    }

    @Bean
    @ConditionalOnBean({Api.class})
    public Animal animal(Api api){
        System.out.println(api.getUrl());
        return new Dog();
    }

}
